package com.accenture.adf.newcodington.module16.activity;
/**
 * Topic : Unit Testing
 * 
 * Description:
 * 
 * The Temperature class allows user to store the current temperature value (temperature),
 * current units of measurement(currUOM) and new units of measurement(newUOM)
 */
public class Temperature {

	// Attributes of the Temperature class to accept temperature, Current and New Units
	private float temperature;
	private char currUOM;
	private char newUOM;
	
	/**
	 * Default constructor to set initial values of 
	 * temperature, currUOM and newUOM values to 32, 'F' and 'C' respectively 
	 */
	public Temperature()
	{
		temperature=32;
		currUOM='F';
		newUOM='C';
	}
	/**
	 * Constructor for accepting temperature and current units 
	 * The only values to be allowed as UOM are 'F' (Fahrenheit), 'C'(Celsius) and 'K'(Kelvin)
	 * 
	 */
	public Temperature(float temperature,char currUOM) throws ArithmeticException,NullPointerException
	{
		//Check if the unit of measure (UOM) is valid and provide a default UOM to convert to.
		if(currUOM != 'F' && currUOM != 'C' && currUOM != 'K')
		{
			throw new ArithmeticException("Invalid Unit of Measure Provided for current UOM:"+currUOM+ ". Value must be  C, F, or K");
		}
		switch (currUOM) {
		case 'C':
			this.newUOM='K';
			break;
		case 'F':
			this.newUOM='C';
			break;
		case 'K':
			this.newUOM='C';
			break;
		}

		this.temperature=temperature;
		this.currUOM=currUOM;
	}
	
	/**
	 * Constructor for accepting temperature, current units and new units 
	 * 
	 */
	public Temperature(float temperature,char currUOM,char newUOM) throws ArithmeticException,NullPointerException
	{
		//Check if the unit of measures (UOM) are valid 
		if(currUOM != 'F' && currUOM != 'C' && currUOM != 'K')
		{
			throw new ArithmeticException("Invalid Unit of Measure Provided for current UOM:"+currUOM+ ". Value must be  C, F, or K");
		}
		if(newUOM != 'F' && newUOM != 'C' && newUOM != 'K')
		{
			throw new ArithmeticException("Invalid Unit of Measure Provided for new UOM:"+newUOM+ ". Value must be  C, F, or K");
		}
		this.temperature=temperature;
		this.currUOM=currUOM;
		this.newUOM=newUOM;
	}	
	
	// Getter and Setter Methods
	
	public float getTemperature() {
		return temperature;
	}
	public void setTemperature(float temperature) {
		this.temperature = temperature;
	}
	public char getCurrUOM() {
		return currUOM;
	}
	public void setCurrUOM(char currUOM) {
		this.currUOM = currUOM;
	}
	public char getNewUOM() {
		return newUOM;
	}
	public void setNewUOM(char newUOM) {
		this.newUOM = newUOM;
	}
	
}
